package com.pty.demo.behaviour.observer;

import java.math.BigDecimal;
import java.util.Observable;
import java.util.Observer;

/**
 * @author pengty
 * @date 2020/3/14
 */
public class PigDealerObserver implements Observer {

    @Override
    public void update(Observable o, Object arg) {
        BigDecimal changeRice = (BigDecimal) arg;
        String str = "上涨 " + changeRice + "元 猪贩子 开心(*^▽^*)";
        if (changeRice.compareTo(BigDecimal.ZERO) < 0) {
            str = "下跌 " + changeRice + " 猪贩子 不开心 ￣へ￣";
        }
        System.out.println("猪肉价格" + str);
    }
}
